package com.epfresh.supplier.entity;

import com.epfresh.api.utils.JsonUtils;
import java.util.Map;

/**
 * @author wangzhanghuan
 * @version 1.0
 * @date create 17-9-4
 * @Description
 */

public class StaffInfo {

    /*{
        "id": 810,
            "accountId": 511,
            "merchantId": 663,
            "name": "逻辑2",
            "phone": "18621643731",
            "owned": false,
            "status": null,
            "createdTime": "2017-09-06 19:13:25",
            "modifiedTime": "2017-09-06 19:26:55",
            "roleIds": null,
            "merchant": {
        "id": 663,
                "name": "测试账号002",
                "shortName": "",
                "certId": null,
                "storeId": 370,
                "createdTime": "2017-09-06 19:04:04",
                "contactName": "",
                "contactPhone": "",
                "provinceCode": "64",
                "cityCode": "6401",
                "districtCode": "640101",
                "provinceName": "宁夏",
                "cityName": "银川市",
                "districtName": "市辖区",
                "address": "",
                "storeName": "9月6号测试店铺",
                "auth": {
            "id": 112,
                    "sale": true,
                    "purchase": false,
                    "process": false,
                    "distribution": false,
                    "warehouse": false,
                    "pickupByCustomer": false,
                    "deliveryForOthers": false,
                    "splitOrder": true,
                    "needBind": false,
                    "storeCategoryType": 1,
                    "beginTime": null,
                    "endTime": null,
                    "merchantId": 663
        },
        "resources": null,
                "lastUsed": null,
                "merchantName": null,
                "openedAreaCode": null,
                "storeStatus": 2
    },
        "account": null,
            "remark": null
    }*/

    /*{
        "id": 333,
            "accountId": 1912,
            "merchantId": 255,
            "name": "",
            "phone": "13644030121",
            "owned": false,
            "status": 1,
            "createdTime": null,
            "modifiedTime": "2017-08-31 14:13:19",
            "roleIds": "",
            "merchant": {
        "id": 255,
                "name": "大脚丫杂货铺",
                "shortName": "",
                "type": null,
                "certStatus": 0,
                "certId": null,
                "storeId": 256,
                "createdTime": null,
                "contactName": null,
                "contactPhone": null,
                "provinceCode": null,
                "cityCode": null,
                "districtCode": null,
                "provinceName": null,
                "cityName": null,
                "districtName": null,
                "address": null,
                "storeName": "大脚丫杂货铺",
                "auth": {
            "id": 18,
                    "sale": true,
                    "purchase": false,
                    "process": false,
                    "distribution": false,
                    "warehouse": false,
                    "pickupByCustomer": false,
                    "deliveryForOthers": false,
                    "splitOrder": false,
                    "priceMode": 1,
                    "priceGroupType": 1,
                    "needBind": false,
                    "storeCategoryType": 1,
                    "saleChannelApp": true,
                    "saleChannelPos": true,
                    "beginTime": null,
                    "endTime": null,
                    "merchantId": 255
        },
        "resources": null,
                "lastUsed": null,
                "merchantName": null,
                "openedAreaCode": null,
                "storeStatus": null
    },
        "account": null
    }*/

    /*{

        //客户权限
        "root.app.pos.customer" : true,
            "root.app.pos.order" : true,
            "root.app.supplier.store" : true,
            "root.app.supplier.product.price_and_purchase" : true,
            "root.app.supplier.store.decoration" : true,
            "root.app.supplier.order.jmt" : true,
            "root.app.supplier.product.selling" : true,
            //台帐
            "root.app.supplier.standing_book" : true,
            //收款
            "root.app.pos.write_off" : true,
            "root.app.supplier.product.presell" : true,
            "root.app.supplier.employee" : true,
            "root.app.supplier.income" : true,
            "root.app.supplier.customer" : true,
            //开单
            "root.app.supplier.order" : true,
            "root.app.supplier.buy" : true,
            "root.app.supplier.coupon" : true,
            "root.app.supplier.push_message" : true,
            "root.app.pos.standing_book" : true,
            "root.app.supplier.comment" : true
    }*/
    String id;
    String accountId;
    String merchantId;
    String name;
    String phone;
    Boolean owned;
    String status;
    String roleIds;
    MerChantInfo merchant;
    Map<String, Object> resources;
    //是否是选中
    private boolean isSelect ;

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public boolean isOwned() {
        return owned == null ? false : owned;
    }

    public void setOwned(boolean owned) {
        this.owned = owned;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(String roleIds) {
        this.roleIds = roleIds;
    }

    public MerChantInfo getMerchant() {
        return merchant;
    }

    public void setMerchant(MerChantInfo merchant) {
        this.merchant = merchant;
    }


    public Map<String, Object> getResources() {
        return resources;
    }

    public void setResources(Map<String, Object> resources) {
        this.resources = resources;
    }


    //客户权限 "root.app.pos.customer"
    public boolean isCustomer() {
        return isResources("root.app.pos.customer");
    }
    //台帐 "root.app.supplier.standing_book"
    public boolean isStandingBook() {
        return isResources("root.app.pos.standing_book");
    }

    //收款"root.app.pos.write_off" : true,
    public boolean isWriteOff() {
        return isResources("root.app.pos.write_off");
    }

    //开单"root.app.supplier.order" : true,
    public boolean isOrder() {
        return isResources("root.app.pos.order");
    }

    public boolean isResources(String key){
        if (resources != null) {
            Object o = resources.get(key);
            if (o != null && o instanceof Boolean) {
                return true;
            }
        }

        return false;
    }
    public Boolean getResourcesItem(String key){
        if (resources != null) {
            Object o = resources.get(key);
            if (o != null && o instanceof Boolean) {
                return true;
            }
        }

        return null;
    }

    @Override
    public String toString() {
        return JsonUtils.toJson(this);
    }
}
